package com.bw.doctor.controller;/**
 * @Author：尚志豪
 * @Package：com.bw.doctor.controller
 * @Project：doudi-group2-shixun-02
 * @name：PharmacyController
 * @Date：2025/2/25 11:46
 */

import com.bw.common.core.domain.Result;
import com.bw.common.core.web.controller.BaseController;
import com.bw.doctor.domain.Patient;
import com.bw.doctor.domain.Prescription;
import com.bw.doctor.domain.Restoratives;
import com.bw.doctor.domain.res.PrescriptionRes;
import com.bw.doctor.service.PharmacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: doudi-group2-shixun-02
 * @description: 我的药房
 * @author: CuiFu Bo
 * @create: 2025-02-25 11:46
 **/
@RestController
@RequestMapping("/pharmacy")
public class PharmacyController extends BaseController
{
    @Autowired
    private PharmacyService pharmacyService;

    /**
     * B端 我的药房 常用药列表
     */
    @PostMapping("/listOfCommonDrugs")
    public Result listOfCommonDrugs(Long doctorId)
    {
        startPage();
        List<Restoratives> list = pharmacyService.listOfCommonDrugs(doctorId);
        return getDataTable(list);
    }
    /**
     * B端 我的药房 常用药删除
     */
    @PostMapping("/deletionOfCommonDrugs")
    public Result deletionOfCommonDrugs(Long restorativesId, Long doctorId)
    {
         pharmacyService.deletionOfCommonDrugs(restorativesId,doctorId);
         return Result.success("常用药删除成功");
    }
    /**
     * B端 我的药房 常用药详情
     */
    @PostMapping("/detailsOfCommonDrugs")
    public Result<Restoratives> detailsOfCommonDrugs( Long restorativesId)
    {
        Restoratives restoratives = pharmacyService.detailsOfCommonDrugs(restorativesId);
        return Result.success(restoratives);
    }
    /**
     * B端 我的药房 常用药添加
     */
    @PostMapping("/additionOfCommonDrugs")
    public Result additionOfCommonDrugs( Long restorativesId, Long doctorId)
    {
        pharmacyService.additionOfCommonDrugs(restorativesId, doctorId);
        return Result.success("常用药添加成功");
    }




    /**
     * B端 我的药房 常用处方添加
     */
    @PostMapping("/commonlyPrescribedAddition")
    public Result commonlyPrescribedAddition ( Prescription prescription, List<Long> ids,Long doctorId )
    {
        pharmacyService.commonlyPrescribedAddition(prescription,ids,doctorId);
        return Result.success("常用处方添加成功");
    }
    /**
     * B端 我的药房 常用处方删除
     */
    @PostMapping("/commonPrescriptionDeletion")
    public Result commonPrescriptionDeletion( Long prescriptionId)
    {
        pharmacyService.commonPrescriptionDeletion(prescriptionId);
        return Result.success("常用处方添加成功");
    }
    /**
     * B端 我的药房 常用处方病症详情
     */
    @PostMapping("/commonPrescriptionDetails")
    public Result<Prescription> commonPrescriptionDetails( Long prescriptionId)
    {
        Prescription prescription = pharmacyService.commonPrescriptionDetails(prescriptionId);
       return Result.success(prescription);
    }
    /**
     * B端 我的药房 常用处方药物详情
     */
    @PostMapping("/commonPrescriptionDetailsMedicine")
    public Result<List<Restoratives>> commonPrescriptionDetailsMedicine( Long prescriptionId)
    {
        List<Restoratives> restorativesList = pharmacyService.commonPrescriptionDetailsMedicine(prescriptionId);
        System.out.println("restorativesList" + restorativesList);
       return Result.success(restorativesList);
    }
    /**
     *  B端 我的药房 常用处方列表
     */
    @PostMapping("/listOfCommonPrescriptions")
    public Result listOfCommonPrescriptions(Long doctorId)
    {
        startPage();
        List<Prescription> list = pharmacyService.listOfCommonPrescriptions(doctorId);
        return getDataTable(list);
    }








}
